package com.dragon.repository.domain.dto;

import com.baomidou.mybatisplus.annotation.TableField;
import com.dragon.repository.entity.Comment;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.dragon.common.util.BeanUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.Date;


/**
 * @author sy
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class CommentDTO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    private Integer id;

    @ApiModelProperty(value = "用户id")
    private Integer adminId;

    @ApiModelProperty(value = "主表id")
    private Integer correlationId;

    @ApiModelProperty(value = "父级评论id")
    private Integer parentId;

    @ApiModelProperty(value = "内容")
    private String replyText;

    @ApiModelProperty(value = "被回复的用户id")
    private Integer replyAdminId;

    @ApiModelProperty(value = "流程类型 跟进记录7 日报26")
    private Integer streamType;

    @ApiModelProperty(value = "评论时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty("用户名称")
    private String username;

    @ApiModelProperty("被回复的用户名称")
    private String replyUsername;

    @ApiModelProperty("头像")
    private String avatar;

    @ApiModelProperty(value = "查出的子评论")
    private List<Comment> subComments;


    public CommentDTO() {}

    public CommentDTO(Comment entity) {
        BeanUtils.copyProperties(entity,this);
    }

    public static CommentDTO convert(Comment entity) {
        return new CommentDTO(entity);
    }

    public static List<CommentDTO> convertList(List<Comment> list) {
        List<CommentDTO> resultList = new ArrayList<>();
        for (Comment entity : list) {
            resultList.add(new CommentDTO(entity));
        }
        return resultList;
    }}
